import QtQuick 2.6
import QtQuick.Layouts 1.2

import "../../../Base/UiBase"
import "../../../Base/Config"
import Code 1.0
import TCItem 1.0

import Cpp.Type 1.0

RowLayout {
    id: headBlock

    property alias headSource: headImage.source
    property alias usernameText: username.text
    property int subject
    property alias postTime: postTime.time
    property string province
    property string city

    height: 90 * Size.ratio

    anchors {
        left: parent.left
        right: parent.right
    }
    Item {
        id: headImageBlock
        width: 90 * Size.ratio
        height: 90 * Size.ratio
        SvgzImage {
            id: headImage

            width: 72 * Size.ratio
            height: 72 * Size.ratio
            anchors.centerIn: parent
        }
    }
    ColumnLayout {
        height: headImage.height
        anchors {
            left: headImageBlock.right
            right: headBlock.right
            verticalCenter: headImageBlock.verticalCenter
        }
        spacing: 0

        Text {
            id: username
            Layout.alignment: Qt.AlignTop
            Layout.preferredHeight: contentHeight

            font.pixelSize: Size.normalFont
        }
        SubjectImage {
            Layout.alignment: Qt.AlignVCenter
            Layout.preferredWidth: width
            Layout.preferredHeight: height
            subject: root.subject
        }

        Text {
            id: location
            Layout.alignment: Qt.AlignBottom
            Layout.preferredHeight: contentHeight
            font.pixelSize: Size.smallFont

            text: province + " " +city

            Text {
                id: postTime
                property date time

                anchors.verticalCenter: location.verticalCenter
                x: root.width - contentWidth - headImageBlock.width - 10 * Size.ratio
                text: Helper.dateToReadable(time)
                font.pixelSize: Size.smallFont
            }
        }
    }
}
